<?php
declare(strict_types=1);

namespace App\Dao;

use App\Model\RolePermission;

class RolePermissionDao
{
    
    public function add($data)
    {
        return RolePermission::create($data);
    }

    public function insert($data)
    {
        return RolePermission::insert($data);
    }

    public function update($where,$data)
    {
        return RolePermission::query()->where($where)->update($data);
    }

    public function delete($where)
    {
        return RolePermission::query()->whereIn('role_id', $where)->delete();
    }
    //通过角色找权限id
    public function peridByRoleid($where)
    {
        return RolePermission::query()->where($where)->pluck('permission_id')->toArray();
    }

    //通过条件统计数量角色
    public function countByWhere($where = []){
        return RolePermission::query()->where($where)->count();
        
    }

    
}
